//
//  UIColor+HMUtilities.m
//  美团
//
//  Created by 谭伟 on 16/10/10.
//  Copyright © 2016年 谭伟. All rights reserved.
//

#import "UIColor+HMUtilities.h"

@implementation UIColor (HMUtilities)

+ (instancetype)colorWithHex:(u_int32_t)hex
{
    // u_int32_t 表示4个字节的长度 , FFFFFF只需要3个字节, 没有3个
    u_int8_t R = hex & 0xff0000 >> 16;
    u_int8_t G = hex & 0x00ff00 >> 8;
    u_int8_t B = hex & 0x0000ff;
    
    return [UIColor colorWithRed:R / 255.0 green:G / 255.0 blue:B / 255.0 alpha:1.0];
}

+ (instancetype)randomColor
{
    return [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0 blue:arc4random_uniform(256) / 255.0 alpha:1.0];
}

@end
